using System;
using System.Collections.Generic;
using System.Text;
using Csla.Data;

namespace MinaspetroLibrary.ProgramacaoPack
{
    [Serializable()]
    public class ProgramacaoCadastroChildInfo : Csla.ReadOnlyBase<ProgramacaoCadastroChildInfo>
    {
        #region Business Properties and Methods

        //declare members

        private Guid _id = Guid.NewGuid();

        private Guid _programacaoId = Guid.Empty;

        private string _empresa = string.Empty;

        private string _cNPJ = string.Empty;

        private string _endereco = string.Empty;

        private string _cidade = string.Empty;

        private string _bairro = string.Empty;

        private string _cEP = string.Empty;

        private string _telefone = string.Empty;

        private string _estado = string.Empty;

        private bool _socio = false;

        private bool _conviteAdicional = false;

        private string _nome = string.Empty;

        private string _email = string.Empty;

        private DateTime _dataInscricao = DateTime.Now;

        [System.ComponentModel.DataObjectField(true, true)]
        public Guid Id
        {
            get
            {
                return _id;
            }
        }

        public Guid ProgramacaoId
        {
            get
            {
                return _programacaoId;
            }
        }

        public string Empresa
        {
            get
            {
                return _empresa;
            }
        }

        public string CNPJ
        {
            get
            {
                return _cNPJ;
            }
        }

        public string Endereco
        {
            get
            {
                return _endereco;
            }
        }

        public string Cidade
        {
            get
            {
                return _cidade;
            }
        }

        public string Bairro
        {
            get
            {
                return _bairro;
            }
        }

        public string CEP
        {
            get
            {
                return _cEP;
            }
        }

        public string Telefone
        {
            get
            {
                return _telefone;
            }
        }

        public string Estado
        {
            get
            {
                return _estado;
            }
        }

        public bool Socio
        {
            get
            {
                return _socio;
            }
        }

        public string SocioString
        {
            get
            {
                if (_socio)
                    return "Socio";
                return string.Empty;
            }
        }

        public bool ConviteAdicional
        {
            get
            {
                return _conviteAdicional;
            }
        }

        public string ConviteAdicionalString
        {
            get
            {
                if (_conviteAdicional)
                    return "ConviteAdicional";
                return string.Empty;
            }
        }

        public string Nome
        {
            get
            {
                return _nome;
            }
        }

        public string Email
        {
            get
            {
                return _email;
            }
        }

        public DateTime DataInscricao
        {
            get
            {
                return _dataInscricao;
            }
        }

        public string DataInscricaoShortString
        {
            get
            {
                return _dataInscricao.ToString("dd/MM/yyyy");
            }
        }

        public string DataInscricaoFullString
        {
            get
            {
                return _dataInscricao.ToString("dd/MM/yyyy HH:mm");
            }
        }


        protected override object GetIdValue()
        {
            return _id.ToString();
        }

        #endregion //Business Properties and Methods

        #region Authorization Rules
        protected override void AddAuthorizationRules()
        {
            //TODO: Define authorization rules in ProgramacaoCadastroChildInfo

        }

        #endregion //Authorization Rules

        #region Factory Methods
        internal static ProgramacaoCadastroChildInfo GetProgramacaoCadastroChildInfo(SafeDataReader dr)
        {
            return new ProgramacaoCadastroChildInfo(dr);
        }

        private ProgramacaoCadastroChildInfo(SafeDataReader dr)
        {
            Fetch(dr);
        }
        #endregion //Factory Methods

        #region Data Access

        #region Data Access - Fetch
        private void Fetch(SafeDataReader dr)
        {
            FetchObject(dr);

            //load child object(s)
            FetchChildren(dr);

        }

        private void FetchObject(SafeDataReader dr)
        {
            _id = new Guid(dr["Id"].ToString());
            _programacaoId = new Guid(dr["ProgramacaoId"].ToString());
            _empresa = dr.GetString("Empresa");
            _cNPJ = dr.GetString("CNPJ");
            _endereco = dr.GetString("Endereco");
            _cidade = dr.GetString("Cidade");
            _bairro = dr.GetString("Bairro");
            _cEP = dr.GetString("CEP");
            _telefone = dr.GetString("Telefone");
            _estado = dr.GetString("Estado");
            _socio = dr.GetBoolean("Socio");
            _conviteAdicional = dr.GetBoolean("ConviteAdicional");
            _nome = dr.GetString("Nome");
            _email = dr.GetString("Email");
            _dataInscricao = dr.GetDateTime("DataInscricao");

        }

        private void FetchChildren(SafeDataReader dr)
        {
        }
        #endregion //Data Access - Fetch
        #endregion //Data Access
    }
}
